import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int t = in.nextInt();
        int H,h,A,a;
        while (t -- != 0){
            h = in.nextInt();
            a = in.nextInt();
            H = in.nextInt();
            A = in.nextInt();
            if(a >= H){
                System.out.println(-1);
            }else {
                int m = H / a + (H % a != 0 ? 1 : 0);
                int n = m - 1;
                int x = n * A;
                int ret = h / x - (h % x == 0 ? 1 : 0);
                System.out.println(ret);
            }
        }
    }
}